﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.Mail;
using System.Diagnostics;

namespace Antix.Mail.Tester {
    public partial class MessageForm : Form {
        public MessageForm() {
            InitializeComponent();
        }

        private void sendButton_Click(object sender, EventArgs e) {

            try {
                var message = new MailMessage();

                message.From = new MailAddress(fromTextBox.Text);
                message.To.Add(toTextBox.Text);
                message.Subject = subjectTextbox.Text;
                message.Body = bodyTextbox.Text;

                new SmtpClient("localhost", 25).Send(message);

                statusLabel.Text = string.Format("'{0}' send on {1}", subjectTextbox.Text, DateTime.Now);
            } catch (Exception ex) {
                Debug.Write(ex.ToString());
                statusLabel.Text = ex.Message;
            }
        }
    }
}
